'use strict';
module.exports = (sequelize, DataTypes) => {
  const Order = sequelize.define('Order', {
    coinCost: DataTypes.INTEGER,
    note: DataTypes.STRING,
    totalPrice: DataTypes.INTEGER,
    status: DataTypes.STRING,
    returned: DataTypes.BOOLEAN,
    currency: DataTypes.STRING,

  }, {});
  Order.associate = function(models) {
    // associations can be defined here
    Order.hasOne(models.Cart);
    Order.belongsTo(models.User, {foreignKey: 'userId', targetKey: 'id'});
    Order.belongsTo(models.Cart);
    Order.belongsTo(models.User, {foreignKey: 'dealer', targetKey: 'id'});
  };
  return Order;
};